import { Pipe, PipeTransform, NgModule } from '@angular/core';

@Pipe({ name: 'hm' })
export class HMPipe implements PipeTransform {
  transform(value, args: string[]): any {
    var day = Math.floor(value / 60 / 24);
    value = value - day * 24 * 60;
    var hour = Math.floor(value / 60);
    value = value - hour * 60;
    if (day > 0) {
      value = day + '天' + hour + '小时' + value + '分钟';
    }
    else {
      value = hour + '小时' + value + '分钟';
    }
    return value;
  }
}

@NgModule({
  declarations: [
    HMPipe
  ],
  exports: [HMPipe]
})

export class HMModule { }
